package Flower;
import org.w3c.dom.ls.LSOutput;

import java.util.Scanner;
public class Flower {
    public static final Flowerjilu flower[] = new Flowerjilu[5];

    static{
        flower[0] = new Flowerjilu("1001", "金色玫瑰", 10, 318.0, "2016-12-12", "王二", "");
        flower[1] = new Flowerjilu("1002", "白玫瑰", 99, 538.0, "2016-12-20", "张欣雨", "");
        flower[2] = new Flowerjilu("1003", "紫色桔梗", 40, 148.0, "2016-12-24", "王二", "烟波");
        flower[3] = new Flowerjilu("1004", "粉色百合", 120, 188.0, "2016-12-26", "王二", "内存");
        flower[4] = new Flowerjilu("1005", "无声", 1000, 219.0, "2016-12-18", "张欣雨", "我");
    }
    //创建键盘输入
    public static final Scanner input = new Scanner(System.in);

    public static void main(String[] args) {
        //死循环
        main:while(true){
            //界面
            System.out.println();
            System.out.println("===============================================");
            System.out.println("编号"+"\t"+"鲜花名称"+"\t"+"销售数量"+"\t"+"价格"+"\t"+"销售日期"+"\t"+"销售员"+"\t"+"备注");
            //遍历数组
            for (int i = 0; i < flower.length; i++) {
                System.out.println(flower[i].getNum()+""+flower[i].getName()+""+flower[i].getTakenum()+""+flower[i].getPrice()+""+flower[i].getData()+""+flower[i].getPerson()+""+flower[i].getDercible());
            }
            System.out.println("===============================================");
            System.out.println();
            //请输入一个数
            System.out.println("请输入一个1-4的整数");
            int a=input.nextInt();
            //判断输入
            switch(a){
                case 1:
                    //查询销量订单
                    find();
                    break;
                case 2:
                    //修改销售订单
                    updata();
                    break;
                case 3:
                    //删除销售订单
                    delete();
                    break;
                default:
                    //系统退出
                    System.out.println("系统退出");
                    break main;
            }
        }
    }

    //查询效销量订单
    public static void find(){
        System.out.println("编号"+"\t"+"鲜花名称"+"\t"+"销售数量"+"\t"+"价格"+"\t"+"销售日期"+"\t"+"销售员"+"\t"+"备注");
        //遍历数组
        for (int i = 0; i < flower.length; i++) {
            System.out.println(flower[i].getNum()+""+flower[i].getName()+""+flower[i].getTakenum()+""+flower[i].getPrice()+""+flower[i].getData()+""+flower[i].getPerson()+""+flower[i].getDercible());
        }
    }
    public static void updata(){
        System.out.println("输入销售编号：");
        String b=input.next();
        //输入数据校验
        boolean c=false;
        for(int i=0;i<5;i++){
            if(flower[i].getNum().equals(b)){
                c=true;
            }
        }
        if(!c){
            System.out.println("输入有误");
            return;
        }
        System.out.println("你要修改的订单详细情况如下：");
        System.out.println("编号"+"\t"+"鲜花名称"+"\t"+"销售数量"+"\t"+"价格"+"\t"+"销售日期"+"\t"+"销售员"+"\t"+"备注");
        //遍历数组
        for (int i = 0; i < flower.length; i++) {
            if(flower[i].getNum().equals(b)){
                System.out.println(flower[i].getNum()+""+flower[i].getName()+""+flower[i].getTakenum()+""+flower[i].getPrice()+""+flower[i].getData()+""+flower[i].getPerson()+""+flower[i].getDercible());
            }
        }
        System.out.println("请输入修改后的鲜花名称：");
        String newName=input.next();
        System.out.println("请输入修改后的销售数量：");
        int newTakeNum=input.nextInt();
        System.out.println("请输入修改后的鲜花价格");
        int newPrice=input.nextInt();
        System.out.println("请输入修改后的销售日期");
        String newData=input.next();
        System.out.println("请输入修改后的销售员");
        String newPerson=input.next();
        System.out.println("请输入修改后的备注");
        String newDercible=input.next();

        //封装这些成员变量
        Flowerjilu xiu=new Flowerjilu(b,newName,newTakeNum,newPrice,newData,newPerson,newDercible);

        System.out.println("您确定压迫修改吗？(y/n)");
        String d = input.next();
        if("y".equals(d)){
            //修改
            for (int i = 0; i <6; i++) {
                if(flower[i].getNum().equals(b)){
                    flower[i] = xiu;
                    break;
                }
            }
            System.out.println("修改成功！");
        }

        // 重新查询一遍
        find();
    }


    //删除方法
    public static void delete(){
        System.out.println("输入想要删除的编号");
        String e=input.next();
        boolean r=false;
        for(int i=0;i<5;i++){
            if(flower[i].getNum().equals(e)){
                r=true;
            }
        }
        //封装空的成员变量
        Flowerjilu shan=new Flowerjilu();
        System.out.println("您确定压迫修改吗？(y/n)");
        String g = input.next();
        if("y".equals(g)){
            //修改
            for (int i = 0; i <6; i++) {
                if(flower[i].getNum().equals(e)){
                    flower[i] = shan;
                    break;
                }
            }
            System.out.println("删除成功！");
        }

        // 重新查询一遍
        find();

    }
}
class Flowerjilu{
    private String num;
    private String name;
    private int takenum;
    private double price;
    private String data;
    private String person;
    private String dercible;
    //构造方法

    public Flowerjilu(String num, String name, int takenum, double price, String data, String person, String dercible) {
        this.num = num;
        this.name = name;
        this.takenum = takenum;
        this.price = price;
        this.data = data;
        this.person = person;
        this.dercible = dercible;
    }

    public Flowerjilu() {
    }
    //set/get

    public String getNum() {
        return num;
    }

    public void setNum(String num) {
        this.num = num;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getTakenum() {
        return takenum;
    }

    public void setTakenum(int takenum) {
        this.takenum = takenum;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public String getPerson() {
        return person;
    }

    public void setPerson(String person) {
        this.person = person;
    }

    public String getDercible() {
        return dercible;
    }

    public void setDercible(String dercible) {
        this.dercible = dercible;
    }
}
